-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Kirby v4 #52
Support Kirby v4 #52
Conversation
Thanks for your PR: I think we could create an alias class for the old So something like: <?php
namespace Kirby\Kql\Interceptors\Cms;
use Kirby\Kql\Interceptors\Content\Content as NewContent;
class Content extends NewContent
{
} |
Thanks for the hint! To add backwards compatibility to my Kirby 3 projects, I currently rely on a similar class alias for my libraries, which basically only require one change for Kirby 4 compatibility: // Add backwards compatibility for Kirby 3
if (!class_exists('Kirby\Content\Field')) {
class_alias('Kirby\Cms\Field', 'Kirby\Content\Field');
} I'm not sure my PHP knowledge will be sufficient to replicate that using your approach for my PR, but I will give it a shot. |
Thanks for the ideas @lukasbestle, which I have implemented accordingly. But I'm running into a problem with Psalm that I can't seem to solve. Perhaps the solution is obvious to you. |
Hm, good point. Maybe a class alias could actually work as well: use Kirby\Kql\Interceptors\Content\Content;
use Kirby\Kql\Interceptors\Content\Field;
class_alias(Content::class, 'Kirby\Kql\Interceptors\Cms\Content');
class_alias(Field::class, 'Kirby\Kql\Interceptors\Cms\Field'); |
Could you please revert |
For sure! Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your work. 💛
Code-wise it looks good to me. Waiting for a second review from Bastian or Nico to confirm that this is the correct solution. Also it still needs real-world testing.
Great! Thanks for the mentoring on this PR, @lukasbestle. Pretty insightful. 🙂 Regarding real-live testing, I'm using my fork (on which this PR is based on) for both K3 in production and a K4 test site. I can verify it works. This is my setup (relevant lines extracted): {
"require": {
"getkirby/cms": "^3.9",
"getkirby/kql": "dev-v4-compat"
},
"repositories": [
{
"url": "https://github.com/johannschopplich/kql-fork.git",
"type": "git"
}
]
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy with this. Thanks for the PR!
This PR 1️⃣ renames the Content and Field class aliases:
Kirby\Cms\Field
class toKirby\Content\Field
Kirby\Cms\Content
class toKirby\Content\Content
While 2️⃣ adding an interceptor alias to keep support for Kirby 3.